<?php
include_once('common/header.php');
$strHexId	= $objRequest->getParam('ch', '');
$strEmail	= $objRequest->getParam('ce', '');
$strTime	= $objRequest->getParam('ct', '');

$intHexId	= Vfriend_Function::base64D($strHexId);
$strEmail	= Vfriend_Function::base64D($strEmail);
$intCurrent	= time();
$intTime	= Vfriend_Function::base64D($strTime);
$intError	= 0;
if($intHexId && $strEmail && $intTime) {
	if($intTime < $intCurrent) {
		$intError = 14;
	}
	$objVfriendUser = new Vfriend_User();
	$objUser		= $objVfriendUser->getInfoByHexUserId($intHexId);
	if($objUser) {
		$intError = $objVfriendUser->updateEmail($objUser->id, $strEmail, 1);
		if($intError == 0) {
			Vfriend_Function::deleteCookie(COOKIE_VFRIEND_AUTH);
			Vfriend_Session::end(0);
			if (isset($_SESSION) && $_SESSION) {
				session_regenerate_id();
				foreach ($_SESSION as $key=>$value) {
					if ($key != SESSION_BACKURL) {
						unset($_SESSION[$key]);
					}
				}
			}				
			Vfriend_Function::setMsg($arrMessage[2]);
			$this->_redirect(HOST_VFRIEND);
		}
		else {
			$intError = 16;
		}
	} else {
		$intError = 15;
	}
}
else {
	$intError	= 13;
}
if($intError > 0) {
	Vfriend_Function::setError($arrError[$intError]);
	$this->_redirect(HOST_VFRIEND);
}
?>